<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: DMLYS
  Date: 2019/7/16
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>list page</title>
    <%--    加入静态资源是,需要配置spirngmvc--%>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<script>
    $(function () {
        $(".delete").click(function () {
            var href = $(this).attr("href");
            $("form").attr("action", href).submit();
            return false;
        });
    })
</script>
<c:if test="${empty requestScope.employees}">
    没有任何员工信息
</c:if>
<c:if test="${!empty requestScope.employees}">
    <table border="1" cellpadding="10" cellspacing="0">
        <tr>
            <th>ID</th>
            <th>LastName</th>
            <th>Email</th>
            <th>Gender</th>
            <th>Department</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
        <c:forEach items="${requestScope.employees}" var="emp">
            <tr>
                <th>${emp.id}</th>
                <th>${emp.lastName}</th>
                <th>${emp.email}</th>
                <th>${emp.gender}</th>
                <th>${emp.department.departmentName}</th>
                <th><a href="/emp/${emp.id}">Edit</a></th>
                <th><a href="/emp/${emp.id}" class="delete">Delete</a></th>
            </tr>
        </c:forEach>
    </table>
</c:if>
<form method="post" action="">
    <input type="hidden" value="DELETE" name="_method">
</form>
<a href="/emp">添加新员工</a>
</body>
</html>
